Fix CodeQL call-graph edges dropped on (file, start_line) join miss (#25)#26
Merged
Merged
Conversation
) CodeQL endpoints were joined into Jedi's PyCallable signature space by an exact (absolute_file_path, start_line) key. When CodeQL and Jedi disagree on a definition's start line (commonly with decorated functions), the caller lookup missed and the whole edge was silently discarded; callee misses degraded to ghost nodes. Replace the exact-only location index with a resolution ladder: exact (file, start_line) -> candidates sharing (file, short_name) (single candidate taken directly, else nearest start_line among those whose parameter count matches the CodeQL positional arity) -> no match (caller skipped / callee ghost, unchanged). The CodeQL query now emits Function.getName() and positional arity for both endpoints, with the callee bound to a Function via calleeVal.getScope(). Bump version to 0.1.15 and update CHANGELOG.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
CodeQL-derived call-graph edges are joined back into Jedi's
PyCallablesignature space by an exact
(absolute_file_path, start_line)key. WhenCodeQL and Jedi disagree on a definition's start line — most commonly
with decorated functions, where the two tools differ on whether the
defline or the first decorator line is the start — the caller lookupmissed and the entire edge was silently discarded (callee misses
degraded to ghost nodes). Jedi-derived edges, which are not
location-joined, were unaffected.
Fixes #25.
Steps to Reproduce
enabled (
--codeql).Expected Behavior
The CodeQL-resolved edge is preserved even when the start line does not
match Jedi's.
Actual Behavior
The edge was dropped (caller miss) or weakened to a ghost node (callee
miss) with only a debug-level log line.
Fix
Replaced the exact-only location index with a resolution ladder:
(abs_path, start_line)— unchanged precise path;(abs_path, short_name): a singlecandidate is taken directly, otherwise prefer those whose parameter
count equals the CodeQL positional arity, then the nearest
start_line;behavior).
The CodeQL query now emits
Function.getName()and positional arity(
count(Function.getArg(_))) for both endpoints, with the callee boundto a
FunctionviacalleeVal.getScope(). Jedi's parameter countincludes
*args/**kwargs/keyword-only slots while CodeQL's arity ispositional only, so the arity filter is exact for plain signatures and
yields to the nearest-line tiebreak otherwise.
Testing
test_cli_helpandtest_single_filepass.test_cli_call_symbol_table_with_jsonfails on this machine due to apre-existing, environment-dependent venv-build flake (
No module named pipduring xarray's editable install incore.py) — unrelated tothis change (it runs with
--no-codeql) and the subject of Decouple cache tiers: key the venv on dependency content, not directory existence #24.produced a valid call graph with edges correctly carrying
["codeql","jedi"]provenance and resolving to properPyCallablesignatures (no spurious ghosts), confirming the new query columns and
resolver work end-to-end.
Version
Patch bump
0.1.14->0.1.15; CHANGELOG updated.